import React from 'react'
// ===================================================================== Temp
import SubmitForm from '#cpt/temp/SubmitForm'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== antd
const $cache = $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		formData: [
			{ label: '标本条码',		name: 'spec_code',  	half:true, required:true, disabled:true },
			{ label: '类型',			name: 'type',  			half:true, required:true, type:'select' },
			{ label: '姓名',			name: 'patient_name',  	half:true, required:true },
			{ label: '医院',			name: 'hosp_id',  		half:true, required:true, type:'select' },
			{ label: '内容',			name: 'content',  		half:true, type:'textarea' },
			{ label: '备注',			name: 'remark',  		half:true, type:'textarea' },
			{ label: '图片',			name: 'img',  			half:true, type: 'upload', multiple:true },
		]
	}
	
	model = {}
	
	componentDidMount(){
		this.getModalSelect()
	}
	
	onSubmit = () => this.formRef.submit()
	clear = () => this.formRef.reset()
	setValue = value => {
		this.clear()
		this.formRef.setValue(value)
	}
	
	// 获取弹窗下拉
	getModalSelect = async () => {
		const { formData } = this.state
		$fn.setModalRows(formData, ['hosp_id','type'], ()=>{
			$cache.then( async f => {
				//医院
				$fn.setRow(formData, 'hosp_id', await f.getCache({api:'hospital'}))
				// 类型
				$fn.setRow(formData, 'type', await f.modification_type)
				this.setState({ formData })
			})
		})
	}
	
	render(){
		return SubmitForm.call(this, { labelWidth:'s6', api:'sp-info-modify/add' })
	}
}

export default Index